package gui.lesson03;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class TestWindow {
    public static void main(String[] args) {
        new WindowFrame();
    }
}
class WindowFrame extends Frame{
    public WindowFrame(){
        setBackground(new Color(222, 33, 33));
        setBounds(100,100,200,200);
        setVisible(true);
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowActivated(WindowEvent e) {
                System.out.println("我是激活窗口");
                Frame source =(Frame) e.getSource();
                source.setTitle("被激活了");
            }
            @Override
            public void windowClosing(WindowEvent e) {
                System.out.println("我是关闭窗口");
                System.exit(0);
            }
        });
    }
}